<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>新增/修改部门</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="">
<meta name="description" content="">
{sys:load href="admin/css/bootstrap.min.css,admin/css/materialdesignicons.min.css,admin/css/style.min.css"}
</head>

<body>
<div class="container-fluid p-t-15">

  <div class="row">
    <div class="col-lg-12">
      <div class="card">
        <div class="card-body">

          <form action="/admin/depart/savedata" method="post" class="row" id="depart">
            <div class="form-group col-md-12">
              <label for="name">部门名称:</label>
              <input type="text" class="form-control" id="name" name="name" value="{$detail.name}" placeholder="请输入部门名称" autocomplete="off" />
            </div>

            {volist name="system_menus" id="menus"}
            <div class="form-group col-md-12 table-responsive">
              <label for="name">{$menus.title}:</label>
              <table class="table table-bordered">
               <tbody>
                   {if condition="isset($menus['son'])"}
                   {foreach $menus['son'] as $mk => $son}
                 <tr>
                   <td class="col-md-1">
                       <label class="lyear-checkbox checkbox-inline checkbox-primary click-node">
                         <input type="checkbox" value="{$son.id}" name="node_indexs[]" {if condition="isset($detail['node_indexs']) && in_array($son['id'], $detail['node_indexs'])"}checked{/if}><span>{$son.title}</span>
                       </label>
                   </td>
                   <td>
                       {if condition="isset( $son['son'] )"}

                       {foreach $son['son'] as $sk => $son_node}
                       <label class="lyear-checkbox checkbox-inline checkbox-primary">
                         <input type="checkbox" value="{$son_node['id']}" name="node_indexs[]" {if condition="isset($detail['node_indexs']) && in_array($son_node['id'], $detail['node_indexs'])"}checked{/if}><span>{$son_node['title']}</span>
                       </label>
                       {/foreach}

                       {/if}
                   </td>
                 </tr>
                 {/foreach}

                 {/if}
               </tbody>
             </table>
            </div>
            {/volist}

            <div class="form-group col-md-12">
                <input type="hidden" name="id" value="{$detail.id}" >
              <button type="button" class="btn btn-primary btn-submit" form-id="depart">确 定</button>
            </div>
          </form>

        </div>
      </div>
    </div>

  </div>

</div>
{sys:load href="admin/lib/layui/layui.js,admin/common.js"}
<script type="text/javascript">
    layui.use(['Request','jquery','layer'], function(){
        var Request = layui.Request,$ = layui.jquery,layer = layui.layer;
        $(".btn-submit").click(function(){
            Request.postInSubmit(".btn-submit", function(response){
                layer.msg('操作成功', {time:1000}, function(){
                    parent.location.reload();
                })
            })
        });

        $(".click-node").click(function(){
            var tdDom = $(this).parent('td').siblings('td').find('input[type=checkbox]');
            if ($(this).find('input[type=checkbox]').is(':checked')) {
                tdDom.attr('checked', true)
            }
        })
    })
</script>
</body>
</html>
